package com.qshu.student.controller;

import com.qshu.student.annotation.AdminLoginToken;
import com.qshu.student.annotation.PassToken;
import com.qshu.student.entity.StudentInfo;
import com.qshu.student.service.studentService;
import com.qshu.student.vo.ResultVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/user")
@Slf4j
public class studentController {
    @Autowired
    studentService service;

    @PassToken
    @GetMapping("/login")
    public List test() {
        return service.getAll();
    }

    //首页获取信息
    @AdminLoginToken
    @PostMapping("/index")
    public ResultVo index(@RequestParam String creatCode) {
        return ResultVo.oK(service.getOnebyCode(creatCode));
    }

    //获取年级
//    @AdminLoginToken
    @PostMapping("/getGradeDesc")
    public ResultVo getGradeDesc() {
        return ResultVo.oK(service.getGrade());
    }

    //获取银行名称
    //    @AdminLoginToken
    @GetMapping("/getBankName")
    public ResultVo getBankName() {
        return ResultVo.oK(service.getBankName());
    }

    //保存信息
//    @AdminLoginToken
    @PostMapping("/addInfo")
    public ResultVo addInfo(@Validated StudentInfo studentInfo) {
        log.info("保存信息", studentInfo);
        return ResultVo.oK(service.insert(studentInfo));
    }

}
